home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / role on / labyrinthii / ps.c < prev    next >
Text File  |  1988-10-02  |  791b  |  29 lines

  1.  
  2. /* Routine to print an unsigned short integer by Russell Wallace 1987. You may
  3.  * copy it freely and use it in your own programs. Requires linkage to my
  4.  * set of console routines, console.o. Use short integer compile option. */
  5.  
  6. printshort (n)
  7. register unsigned short n;
  8. {
  9.     char digits[6];    /* Extra one to hold null to terminate string. */
  10.     register short i;
  11.     register short j=0;
  12.     register short column=10000;
  13.     register char notzero=0;
  14.     for (i=0;i<5;i++)
  15.     {
  16.         digits[j]=(char)(n/column)+'0';
  17.         if (digits[j]!='0')
  18.             notzero++;
  19.         if (notzero)    /* To avoid leading zeros */
  20.             j++;
  21.         n=n%column;
  22.         column/=10;
  23.     }
  24.     if (!notzero)
  25.         digits[j++]='0';
  26.     digits[j]='\0';    /* Print()ed all digits at once rather than use */
  27.     print (digits);    /* writechar() for each so as to get formatted print. */
  28. }
  29.